/*
 *               ____
 *              /\   \
 *             ___\   \___
 *            /\          \
 *            \ \___    ___\
 *        ____ \/__/\   \__/
 *       /\   \    \ \___\    klof  |  innovative web technology
 *      ___\   \___ \/___/
 *     /\          \          klib3/link.js
 *     \ \___    ___\         Link multiple klib3.dynamic objects together
 *      \/__/\   \__/
 *          \ \___\           Copyright 2003-2006, klof
 *           \/___/           http://www.klof.net/k.lib3/
 *
 *                            requirements: klib3/style.js
 *                                          klib3/dynamic.js
 */


/* Create the master klib3 object if she doesn't exist */
if ( typeof klib3 != "object" )
	klib3 = new ( function(){ this._child = 0 } )();


klib3.link = function( mElement )
{
	this._version = "1.0.0";
	this._link    = new Array();
	if ( typeof mElement != "undefined" )
		this.add( mElement );
};
klib3.link.prototype.add = function( mElement )
{
	if ( mElement.__proto__ == Array.prototype ) // Array of elements
		for ( var i = 0; i < mElement.length; ++i )
			this.add( mElement[ i ] );
	else if ( typeof mElement == "object" || typeof mElement == "string" )
		return this._link[ this._link.length ] = new klib3.dynamic( mElement );
};
klib3.link.prototype.call = function( sMethod )
{
	var aParam = new Array();
	if ( arguments.length == 2 && arguments[ 1 ].__proto__ == Array.prototype )
		aParam = arguments[ 1 ];
	else
		for ( var i = 1; i < arguments.length; ++i )
			aParam[ aParam.length ] = arguments[ i ];

	for ( var i = 0; i < this._link.length; ++i )
		this._link[ i ][ sMethod ].apply( this._link[ i ], aParam );
};
